package com.wl.cloud.mbg;

import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
import org.springframework.stereotype.Component;

/**
 * @author: wanglin
 * @date: 2023-09-15 周五
 * @Version: 1.0
 * @Description: 代码生成器支持自定义[DTO\VO等]模版
 */
@Component
public class EnhanceFreemarkerTemplateEngine extends VelocityTemplateEngine {



//    protected void outputCustomFile(Map<String, String> customFile, TableInfo tableInfo, Map<String, Object> objectMap) {
//        String entityName = tableInfo.getEntityName();
//        String otherPath = this.getPathInfo(OutputFile.other);
//        customFile.forEach((key, value) -> {
//            String fileName = String.format(otherPath + File.separator + entityName + "%s", key);
//            this.outputFile(new File(fileName), objectMap, value, true);
//        });
//    }

//    protected void writer(Map<String, String> customFile, TableInfo tableInfo, Map<String, Object> objectMap) {
//        String entityName = tableInfo.getEntityName();
//        String otherPath = this.getPathInfo(OutputFile.other);
//        customFile.forEach((key, value) -> {
//            String fileName = String.format(otherPath + File.separator + entityName + "%s", key);
//            this.outputFile(new File(fileName), objectMap, value, true);
//        });
//    }

//    @Override
//    public void writer(Map<String, Object> objectMap, String templatePath, String outputFile) throws Exception {
//        Template template = velocityEngine.getTemplate(templatePath, ConstVal.UTF8);
//        try (FileOutputStream fos = new FileOutputStream(outputFile);
//             OutputStreamWriter ow = new OutputStreamWriter(fos, ConstVal.UTF8);
//             BufferedWriter writer = new BufferedWriter(ow)) {
//            template.merge(new VelocityContext(objectMap), writer);
//        }
//        logger.debug("模板:" + templatePath + ";  文件:" + outputFile);
//    }

}
